//package com.sunop.pantiai.controller;
//
//import lombok.AllArgsConstructor;
//import org.springframework.ai.chat.client.ChatClient;
//import org.springframework.ai.chat.client.advisor.QuestionAnswerAdvisor;
//import org.springframework.ai.vectorstore.VectorStore;
//import org.springframework.web.bind.annotation.*;
//import reactor.core.publisher.Flux;
//import static org.springframework.ai.chat.client.advisor.AbstractChatMemoryAdvisor.CHAT_MEMORY_CONVERSATION_ID_KEY;
//import static org.springframework.ai.chat.client.advisor.AbstractChatMemoryAdvisor.CHAT_MEMORY_RETRIEVE_SIZE_KEY;
//
//@RestController
//@RequestMapping("/ai")
//@AllArgsConstructor
//public class ChatController {
//
//    private final ChatClient chatClient;
//    private final VectorStore vectorStore;
//
//    @RequestMapping(value = "/chat", produces = "text/plain;charset=utf-8")
//    public Flux<String> chat(
//            @RequestParam("input") String prompt,
//            @RequestParam("chatId") String chatId) {
//        // 1.保存会话id
//
//        return chatClient.prompt()
//                .user(prompt)
//                .advisors(a -> a.param(CHAT_MEMORY_CONVERSATION_ID_KEY, chatId)
//                        .param(CHAT_MEMORY_RETRIEVE_SIZE_KEY, 10))
//                .advisors(new QuestionAnswerAdvisor(vectorStore))
//                .stream()
//                .content();
//    }
//
//}
